<template>
  <div>
    <el-card class="box-card">
      <div slot="header" class="clearfix" style="text-align: center;line-height: 30px">
        <h3>添加出库商品</h3>
      </div>
      <div class="text item">
        <Template :tableinfo="tableinfo" :tablebutton="tablebutton" :totalmsg="totalmsg" :tabledate="tabledate" @init="init" @refresh="refresh" identity="AddSaleCargo"></Template>
        <div style="float: right;width: 350px;height: 300px;margin-top: 40px;margin-right: 100px">
          <el-card class="box-card loginCl">
            <div slot="header" class="clearfix">
              <h3 style="align-content: center;text-align: center">查询商品</h3>
            </div>
            <div class="text item">
              <el-form :model="ruleForm" status-icon ref="ruleForm" label-width="100px" class="demo-ruleForm">
                <el-row class="row-class">
                  <el-col :span="24"><div class="grid-content bg-purple-light">
                    <el-form-item label="商品名称" prop="username">
                      <el-input v-model.number="ruleForm.cargoname"></el-input>
                    </el-form-item>
                  </div>
                  </el-col>
                </el-row>
                <el-row class="row-class">
                  <el-col :span="24"><div class="grid-content bg-purple-light">
                    <el-form-item label="类别" prop="password">
                      <el-input v-model="ruleForm.cargotype" autocomplete="off"></el-input>
                    </el-form-item>
                  </div>
                  </el-col>
                </el-row>

                <div>
                  <el-form-item style="align-content: center;text-align: center">
                    <el-button type="primary" @click="select">查询</el-button>
                  </el-form-item>
                </div>
              </el-form>
            </div>
          </el-card>
        </div>
      </div>
    </el-card>
  </div>
</template>

<script>
import Template from "@/components/Template";

export default {
  name: "AddSaleCargo",
  components: {
    // eslint-disable-next-line vue/no-unused-components
    Template
  },
  data() {
    return {
      tabledate: [],
      totalmsg: 10,

      selectOS: false,

      tableinfo: [['厂家', "cargoFactory"],['建议销售价', "goSalemoney"], ['商品名称', "cargoName"]],
      tablebutton: ['添加'],
      ruleForm: {
        cargoname: '',
        cargotype: ''
      }
    }
  },
  methods: {
    init(pageNum, pageSize) {
      let url = ''
      if (this.selectOS == true) {
        url = "apj/cargo/selectOnePageByInfo"
        let fd = new FormData
        fd.append("pageNum",pageNum)
        fd.append("pageSize",pageSize)
        fd.append("name",this.ruleForm.cargoname)
        fd.append("startTime",this.ruleForm.cargotype)
        this.$axios.post(url,fd).then(r=>{
          let msg = r.data
          this.totalmsg = msg.total
          this.tabledate = msg.records
        })
      } else {
        url = "apj/cargo/selectOnePageCargo/" + pageNum + "/" + pageSize
      }
      this.$axios.get(url).then(r => {
        let msg = r.data
        this.totalmsg = msg.total
        this.tabledate = msg.records
      })
    },
    select() {
      this.selectOS = true
      this.init(1, 4)
    },
    refresh(){
      this.$emit("init")
      this.$emit("close")
    }
  }
}
</script>

<style scoped>

</style>